<?php include PATH_TPL."/admin/tpl.header.phtml"?>
<div class="main-container inner">
    <div class="main-content">
        <div class="container-fluid">
            <div class="row bt">
                <div class="col-lg-12 bg">
                    <ol class="breadcrumb">
                        <li class="active">
                            <i class="fa  fa-fw fa-reorder"></i>  案件管理
                        </li>
                    </ol>
                </div>
            </div>
            <div class="row">
            	<form method="post" action="/admin_sign">
                <div clas="col-md-6">
                    &nbsp;&nbsp;&nbsp;
                		<a class="btn btn-success" id="default">重置</a>
                		<!--<select name="policyno">
                			<option>保单号</option>
                			<?foreach($tPolicy as $tRow){?>
                			<option <?if($tRow['policyno'] == $pPolicyno){
                					echo 'selected';
                				}?>><?=$tRow['policyno']?></option>
                			<?}?>
                		</select>-->
                		<!--<select name="policyname">
                			<option>投保单位</option>
                			<?foreach($tCompany as $tRow){?>
                			<option <?if($tRow['policyname'] == $pPolicyname){
                					echo 'selected';
                				}?>><?=$tRow['policyname']?></option>
                			<?}?>
                		</select>-->
                		<!--<select name="status">
                			<option>签批状态</option>
                			<option value="3" <?if($pStatus == '3'){
                					echo 'selected';
                				}?>>未签批</option>
                			<option value="4" <?if($pStatus == '4'){
                					echo 'selected';
                				}?>>已签批</option>
                		</select>-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                          <button type="button" class="btn btn-default" id="search" href="/admin_sign" style="float:right;right:35px;margin-right:40px;"><i class="fa fa-search"></i></button>
<input type="text" placeholder="请输入姓名关键字" value="<?=$pKey?>" name="key" class="form-controll" style="float:right;width:335px;height:33px;">
                </div>
            </div>
            <div>
                <input type="button" value="签批" name="signBtn" class="btn" /><br />
                <input type="button" value="全选" id="all"/><input type="button" value="反选" id="fan"/>
            </div>
            <div class="panel-body text-center">
                <table class="table table-hover" id="sample-table-1">
                    <thead>
                        <tr>
                            <td></td>
                            <td>CaseID</td>
                            <td>姓名</td>
                            <td>证件类型</td>
                            <td>证件号码</td>
                            <td>华道分案号</td>
                            <td>投保单位
                		<select name="policyname">
                			<option value="">请选择</option>
                			<?foreach($tCompany as $tRow){?>
                			<option <?if($tRow['policyname'] == $pPolicyname){
                					echo 'selected';
                				}?>><?=$tRow['policyname']?></option>
                			<?}?>
                		</select>
							</td>
                            <td>保单号
                		<select name="policyno">
                			<option value="">请选择</option>
                			<?foreach($tPolicy as $tRow){?>
                			<option <?if($tRow['policyno'] == $pPolicyno){
                					echo 'selected';
                				}?>><?=$tRow['policyno']?></option>
                			<?}?>
                		</select>
							</td>
                            <td>用户等级</td>
                            <td>签批状态
                		<select name="status">
                			<option value="">请选择</option>
                			<option value="3" <?if($pStatus == '3'){
                					echo 'selected';
                				}?>>未签批</option>
                			<option value="4" <?if($pStatus == '4'){
                					echo 'selected';
                				}?>>已签批</option>
						</select>
							</td>
                            <td>赔付结论</td>
                            <td>操作</td>
                        </tr>
                    </thead>
                    <?foreach($tDatas as $tRow){?>
                    <tr>
                        <td><input type="checkbox" name="case[]" value="<?=$tRow['case_id']?>" /></td>
                        <td class="id"><?=$tRow['case_id']?></td>
                        <td><?=$tRow['username']?></td>
                        <td><?=$tRow['crittype_info']?></td>
                        <td><?=$tRow['critcode']?></td>
                        <td><?=$tRow['hd_caseno']?></td>
                        <td><?=$tRow['policyname']?></td>
                        <td><?=$tRow['policyno']?></td>
                        <td><?switch ($tRow['insuredgrade']) {
                        		case 0:echo '普通';break;
                        		case 1:echo 'VIP';break;
                        }?></td>
                        <td><?if($tRow['status'] == '3'){
                					echo '未签批';
                				}
                                if($tRow['status'] == '4'){
                					echo '已签批';
                					}?></td>
                        <td><?switch($tRow['is_dishonor']){
                        		case 1:echo '已付';break;
                        		case 2:echo '拒付';break;
                        		case 0:echo '撤单';break;
                        	}?></td>
                        <td>
                            <div class="visible-md visible-lg hidden-sm hidden-xs">
                                <a class="sign btn btn-green btn-xs tooltips" data-placement="top" data-original-title="签批" type="button" data="<?=$tRow['case_id']?>"><i class="glyphicon glyphicon-ok"></i></a>
                            </div>

                            <div class="visible-xs visible-sm hidden-md hidden-lg">
                                <div class="btn-group">
                                    <a class="btn btn-green dropdown-toggle btn-sm" data-toggle="dropdown" href="#">
                                        <i class="fa fa-cog"></i> <span class="caret"></span>
                                    </a>
                                    <ul role="menu" class="dropdown-menu pull-right dropdown-dark">
                                        <li>
                                            <a role="menuitem" tabindex="-1" href="/admin_sign/handle?id=<?=$tRow['case_id']?>">
                                                <i class="fa fa-share"></i>签批
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </td>
                    </tr>
<?}?>
                </table>
<?=$tShow?>
            </div>
        </div>
                    </form>
        <div class="subviews">
            <div class="subviews-container"></div>
        </div>
    </div>
    <!-- end: PAGE -->
</div>
<!-- end: MAIN CONTAINER -->

<script>
$(function(){
    //全选
    $('#all').click(function(){
            $('input[name="case[]"]').attr('checked',true);
    });
    // 反选
    $('#fan').click(function(){
        $('input[name="case[]"]').each(function(){
            this.checked = !this.checked;
            // $(this).attr('checked',!$(this).attr('checked'));
        });
        allCheck();  
    });
    //单选
    $('.sign').click(function(){
        var id = <?=$tRow['case_id']?>;
        $.post('/admin_sign/handle',{id:id},function(obj){
            alert(obj.msg);window.location.href = '/admin_sign';
        });
    });
    $('input[name="signBtn"]').click(function(){
            var id = [];
        //多选
        $('input[name="case[]"]:checked').each(function(){
            id.push($(this).val());
        });
        if(id.length == 0){
            alert('请选择您要签批的案件');return;
        }
        $.post('/admin_sign/handle',{id:id},function(obj){
            alert(obj.msg);window.location.href = '/admin_sign';
        });    
    });
});
function allCheck(){
        var num_all = $('input[name="case[]"]').size();//选项总个数
        var num_checked = $('input[name="case[]"]:checked').size();//选中个数
        if(num_all == num_checked){//若选项总个数等于选中个数
            $('#all').attr('checked',true);//全选选中
        }else{
            $('#all').attr('checked',false);
        }
    }
$('#search').click(function(){
	$('form').submit();
});
$('#default').click(function(){
	window.location.href="/admin_sign";
});
$('select').on('change',function(){
	$('#search').trigger('click');		
});
</script>
<?php include PATH_TPL."/admin/tpl.footer.phtml"?>
